﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace INSE6260.OnlineBanking.Model.Transaction
{
    public class Withdraw : Transaction
    {

        public override void PerformTransaction()
        {
            if (SourceAccount == null)
                throw new Exception("Invalid Source Account");

            if (DestinationAccount == null)
                throw new Exception("Invalid Destination Account");

            if (Amount == 0)
                throw new Exception("Amount is 0");

            if (Amount > SourceAccount.Balance)
                throw new Exception("Insufficient Funds");

            if (Amount > SourceAccount.WPD)
                throw new Exception("Amount is more than WPD");

            if (Amount > SourceAccount.WPT)
                throw new Exception("Amount is more than WPT");

            SourceAccount.Balance -= Amount;
            DestinationAccount.Balance += Amount;
            Balance = SourceAccount.Balance;
        }
    }
}
